 _____________________________________________
|           ___  _____   _____    ___   ___   |
|  |    |  /   \   |       |   | |   \ /   \  |
|  |____| |     |  |       |   | |___/ \___   |
|  |    | |     |  |       |   | |         \  |
|  |    |  \___/   |       |   | |     \___/  |
|                                             |
| There has been a flood of tips since this   |
| section started its life last issue. Keep   |
| them coming - the best one could win you a  |
| few bob.                                    |
|_____________________________________________|

DATA from nowhere
After running the program below, you should find on your disc or tape a file
called DATA.BIN. To load it into memory, type MEMORY 42000:LOAD "DATA.BIN".
    What on earth does the program do? Well, if you have an area of memory full
of code, and you wish to convert that to a list of DATA statements, then this
is for you. The syntax for creating the DATA statements is:

CALL 42001, <start address>, <number of lines>

where start address is the memory location where all the bytes you wish
converted to DATA statements are stored. Number of lines refers to the number
of Basic DATA statements that will be produced.
    So, for example, this line will cause the bytes from address 7000 to be
produced within six DATA statements:

CALL 42001,7000,6

    Type in the listing and you should be well away. Data lines will be
produced identical to these:

[Listing - DATA.BAS]

JT, who forgot to give his address


-------------------------------------------------------------------------------
Bordering on superdazzle
Seeing your attempt last month at making a 'dazzling border' made me laugh.
Here is a Basic program which will give you a much better effect. It will
continue dazzling no matter what the computer is doing!

[Listing - DAZZLE.BAS]

Roy Makely
Hampshire

-------------------------------------------------------------------------------
Muddling modes
Did you know it is possible to mix modes on the screen without having any fancy
interrupts going? No, well read on. If you own a 464 then type in direct mode
the following:

MODE 2
POKE &B1CF,&C0:POKE &B1D0,&30
POKE &B1D1,&0C:POKE &B1D2,&03
POKE &B1C8,1

    For owners of 664s or 6128s:

MODE 2
POKE &B7C6,&C0:POKE &B7C7,&30
POKE &B7C8,&0C:POKE &B7C9,&03
POKE &B7C3,1

    These pokes actually alter data used by the Basic operating system to tell
it which mode is currently in effect and other information regarding screen
layout.
    Unfortunately 664 or 6128 owners will not get quite the desired effect. The
image will appear blurred. Perhaps somebody out there knows differently - if so
please send in details.
    The listing below, for 464 owners only, will allow you to display text in
Mode 2 that is of any Mode size. For example, 80 characters can be displayed in
one line in Mode 2; the program below will allow both 40 and 20 columns of
text. The new commands available are MODE2, MODE1 and MODE0. One restriction to
note, though: make sure you are in Mode 2 before using the routine; otherwise
strange effects will result.

[Listing - MIXMODES.BAS]

Paul Smith
St Helens, Merseyside


-------------------------------------------------------------------------------
PROBLEM ATTIC
-------------------------------------------------------------------------------

Legs eleven
As promised last issue, the best bingo program sent in after DR Brown's plea,
would be printed. Adrian Pegg from Palmers Green in London has come up with a
neat solution. It is short and very nicely executed. All the instructions are
tagged into REM statements.
 ____________________________
|                          |_\
| [Listing - BINGO.BAS]      |
|____________________________|


Back to cassette loading
One point I failed to mention last month concerning external cassette decks:
you may not have remote-control on your deck. This causes problems when loading
certain commercial software that insists on stopping the cassette motor while
it draws a title screen or something.
    There is no simple way of overcoming this problem. The only thing I can
suggest is that every time you hear a relay click in your CPC, pause the tape
till another click.
    There is certain, very old, software that insists of having all the memory
it can grab. Machines with a disk drive will reserve about 500 bytes of memory
- if not more. The result is that these software packages will not run on your
Amstrad. Here is a short program that will reclaim all memory, giving a
completely free machine:
 ____________________________
|                          |_\
| [Listing - ROMDISAB.BAS]   |
|____________________________|


Fabled listing
Here is that promised listing from J Keneally of Exeter. The utility checks the
health of your tape drive - not for azimuth but for defects in the mechanics.
    It works by recording a fixed-frequency test tape, then replaying it to
measure fluctuations in frequency every 0.1 of a second. These are plotted on a
graph as speed variations over 5% of the average.
    Several things can be deduced from the graph. If there is a general trend
downwards with time, it indicates a tight wind-off spool. Occasional sharp
peaks would point to 'snatching' of the spool. A regular variation indicates a
fault related to rotation of a part of the mechanism - the frequency of this
will give a clue to which part.
    At the end of the test you will get a read-out of the maximum and minimum
variation. For a good drive these should be within 1%. Anything over 3%
suggests a problem.
    The most common of these is the pinchwheel.
    The program gives you two more graphs to help in diagnosing this. The first
shows a filtered version of the original graph, making it easier to see any
regular changes. If you can line up the pinchwheel grid with regular peaks (use
Shift and the cursor keys for faster motion) it indicates slippage each time
the pinchwheel rotates. This can be taken further by pressing E to take you
onto a frequency spectrum plot of the section around the grid.

[Listing - SPEEDCHK.BAS]

    That listing ends an exaustive look at tape loading problems; if your
troubles are still not resolved after following all the instructions, then it
is best to take it to your dealer for a professional look.


        / \
      /     \
    /         \
  T Y P E - I N S
/_________________\


Calendar

Here is a very appropriate listing for the January 1987 issue. R Bellerby of
Hessle, North Humberside, has written a brilliant calendar generator. It will
print a calendar for any year between 1800 and 2500 to either screen or
printer.
    The clever thing about the program is that it takes into account not only
leapyears, but also that century years should not be leapyears unless they are
divisible by 400. Thus 1800 and 1900 were not leapyears although 2000 will be.
    You might think the program could be easily amended to print years before
the 1800s. Not so simple. A bit of history: Our present 12-month calendar dates
back to Julius Caesar. It originally did not have the century-year rule, and by
the 1500s was 10 days out of sync with the seasons. In 1582 Pope Gregory
decreed 15 October was to come immediately after 4 October; much of the world
obeyed. But non-Catholic countries weren't in the mood for papal bull. England,
for example, waited until 1752 and dropped 12 days; Russia resisted until
almost 1920.
    So if you want to extend the program before 1800 you'll have to take
political complications into account - you might be able to sell your work to
harrassed historians.

[Listing - CALENDAR.BAS]


Fast Basic double-height

Remember last month's double-height routine by Leighton Derrick from West
Glamorgan? Well, I was inundated with routines for fast double-height written
in Basic.
    The shortest and fastest is by Chris Boothman of Shepton Mallet, Somerset.
It can be easily incorporated into your own programs. Just place the string you
wish to appear double-height into s$; the position where you wish it to be
placed on the screen should be entered into the variables x any y.

[Listing - DHEIGHT.BAS]


Snowstorm

Worried that there will be no white Christmas this year? Fear not, as Shaun
Garrad of Warwickshire has come up with the perfect answer - a snow generator.
Just type in the listing, and marvel at all that snow...
 __________________________
|                          |
| [Listing - SNOW.BAS]     |
|__________________________|


Artist

The listings this month have, in general, greatly increased in size. This one,
from Simon Watson in Cornwall, is no exception. It was chosen from many similar
listings because of its comparative short length, execution speed and
impressive list of options.
    Explanation is in order, as there are no instructions within the program.
First, it is necessary to press the Caps-Lock key before trying anything else,
as the program looks out for upper-case characters. This is a list of options
available and how to access them:
    A - Switches airbrush mode on and off.
    B - Alters brush size of airbrush and paint facilities.
    C - Draws a circle of desired radius.
    D - Draws a filled-in circle of desired radius.
    F - Freehand mode on/off.
    I - Change the ink colour.
    L - Loads a picture into memory.
    N - Alters density of airbrush.
    O - Changes origin to current cursor position.
    P - Painting-brush on/off.
    R - Draws straight line from origin to current cursor position, but does
not alter origin.
    S - Saves a picture.
    T - Draws straight line from origin to cursor position, and changes the
origin.
    X - Plots a single pixel.
    DEL - Deletes the last drawing command from screen.
    Control-W - Wipes picture.

[Listing - ARTIST.BAS]

[There are some bugs in Artist, which Amstrad Action did not correct in any
subsequent issues:

* When changing the colour of an ink, an "Improper argument" error is generated
if the user enters an ink that is greater than 15. To correct this, "I1>26" in
line 380 should be changed to "I1>(4^(2-M))-1". Also, the word "ink" in the
second INPUT command should be changed to "colour".

* There is a missing colon in line 540 between the first GOSUB and RETURN
commands. BASIC 1.0 ignores this, but a "Syntax error" is generated in BASIC
1.1 when the user alters the density of the airbrush and either enters 0 or
presses RETURN or ENTER without entering anything.

* The program copies the screen to an area of memory, but it can become
corrupted because there is no MEMORY command to tell BASIC not to use this area
of memory. To correct this, add the command "MEMORY 24549" after the RESTORE
command in line 650.]


Wandering through space

This is a lovely piece of programming from Julian Smalley of Nottinghamshire.
It uses colour-swapping techniques to give the impression that you are seated
in the cockpit of a spacecraft, watching the stars flash by while the
instruments whirl.

[Listing - WANDER.BAS]


Pyramid

Adrian Sill of Doncaster sent in what was a one-liner. I split it up to make it
more legible. This is an interesting routine, as it shows what is capable with
the minimum of commands.

[Listing - PYRAMID.BAS]


Shady dump

How about this offering from Mark Gannon of Derbyshire? It produces a 16-shade
graphics screendump on your printer. Unfortunately it will work only on Mode 0
screens. More disappointing, though, is that it works only with Amstrad's DMP
2000 printers.
    You may not be overawed by this. However, as Mark says: 'Where the program
scores is that it interrogates each ink and assigns the varying shades
according to the colours as opposed to the inks.' In other words, the program
looks to see what colour is actually inside the inkpot. It certainly works well
- just see the results for yourself.
    Turn off the perforation skip on the printer (dipswitch 2, SW2) before
using the program.
 __________________________
|                          |
| [Listing - SHADYDUM.BAS] |
|__________________________|


Screen squash

Great listing from Simon Solway of Sheffield. It compresses screen data,
therefore reducing the amount of memory needed to store a picture.
Andconsequently it cuts loading and saving time considerably.
    The program, in machine-code, contains two sections: the squash routine and
the unsquash routine.
    To squash a picture, make sure that the image is on screen and Himem is set
to &55FF at most. Then CALL &9700. To save this data, you will have to enter
the following: SAVE"filename", B, &5600, PEEK(&5601) + 256*PEEK(&5602) - &5600
    To unsquash a picture, load the program, then the squashed data at &5600,
and then CALL &97A0.
    Neither routine can cope with screens that have scrolled. So before you
squash or unsquash it's advisable to set the Screen Offset to zero, by entering
a Mode command - do this before drawing a picture.
 __________________________
|                          |
| [Listing - SQUASH.BAS]   |
|__________________________|


[Below is an extract from a letter that was published in the "Hot Tips" section
in the March 1987 issue (#18). Its author provides some additional information
regarding the "Muddling modes" letter.]

Muddling Modes - follow-up
Here is some further information regarding Muddling Modes (Hot Tips, AA 16).
The locations at &B1CF to &B1D2 are the pixel masks used by the screen-writing
routine in the 464 rom. The 664 and 6128 use a different routine which
calculates the masks for each mode, rather than transferring them from rom to
ram; there are therefore no masks to alter. The locations &B7C6 to &B7C9 have
nothing to do with pixel masks - &B7C6 is in fact the high byte of the screen
base address (which is of course &C0). There is thus no way for 664 or 6128
owners to achieve mixed-mode writing without resorting to interrupt-driven
screen splitting. Readers with a 464 might like to try a similar effect mixing
modes 1 and 0 on a mode-1 screen; this gives the advantage of different inks,
and in fact some inks will give a stripey effect:

MODE 1:POKE &B1C8,0;POKE &B1CF,&CC:POKE &B1D0,&33    [return]

    Stripey inks can also be achieved by poking the ink masks (rather than the
pixel masks):

                   464 users    6128 users
pen                &B28F        &B72F
paper              &B290        &B730
graphics pen       &B338        &B6A3
graphics paper     &B339        &B6A4

Ewen Flint
Calside, Dumfries
